part of AppUtils;

extension Other on _AppUtils {
  void reLoadPages() {
    void reloadPage(YPage? page) {
      if (page != null && page.mounted && page.yIsAlive)
        try {
          page.setState(() {});
        } catch (e) {}
    }

    yPages.forEach((yPage) {
      reloadPage(yPage);
      if (yPage is MainPage) {
        yPage.homePages.forEach((page) {
          reloadPage(page);
          if (page is MainPage_Home) {
            page.mainPage_Home_Pages.forEach((page) {
              reloadPage(page);
            });
          }
        });
      }
    });
  }

  void toggleProductShowType(YPage page, {StateSetter? setState}) {
    IFinal.Others.isProductShowGrid = !IFinal.Others.isProductShowGrid;
    ySave(IFinal.Saves.productListIsGrid, IFinal.Others.isProductShowGrid.toString());
    page.yBroadcast_send(IFinal.Broadcasts.refreshHomeTJShowType);
    setState?.call(() {});
    reLoadPages();
  }
}
